/**
 * @file aadl_log.h
 * @brief 
 * @author  ()
 * @version 1.0
 * @date 2024-11-04
 * @defgroup aadl
 * @ingroup library
 * 
 * @copyright Copyright (C) 2019 Queclink Wireless Solutions (ShenZhen) Co., Ltd. All Rights Reserved.
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2024-11-04 <td>1.0     <td>     <td>内容
 * </table>
 */
#ifndef __AADL_LOG_H
#define __AADL_LOG_H


#include "common/qlcommon.h"

#ifndef LOG_TAG
#define LOG_TAG TAG_AADL
#endif
#include "easylog/elog.h"



/* log level definition */
#define LOG_FATAL       "0" /* 关键的,重大的,致命的 */
#define LOG_EMERG       "0" /* system is unusable */
#define LOG_ALERT       "1" /* action must be taken immediately */
#define LOG_CRIT        "2" /* critical conditions */
#define LOG_ERROR       "3" /* error conditions */
#define LOG_ERR         "3" /* error conditions */
#define LOG_WARNING     "4" /* warning conditions */
#define LOG_WARN        "4" /* warning conditions */
#define LOG_NOTICE      "5" /* normal but significant condition */
#define LOG_INFO        "6" /* informational */
#define LOG_DEBUG       "7" /* debug-level messages */

#define LOG_FATAL_C       '0' /* 关键的,重大的,致命的 */
#define LOG_EMERG_C       '0' /* system is unusable */
#define LOG_ALERT_C       '1' /* action must be taken immediately */
#define LOG_CRIT_C        '2' /* critical conditions */
#define LOG_ERR_C         '3' /* error conditions */
#define LOG_ERROR_C       '3' /* error conditions */
#define LOG_WARNING_C     '4' /* warning conditions */
#define LOG_WARN_C        '4' /* warning conditions */
#define LOG_NOTICE_C      '5' /* normal but significant condition */
#define LOG_INFO_C        '6' /* informational */
#define LOG_DEBUG_C       '7' /* debug-level messages */

#define LOG_ALL         LOG_DEBUG
#define LOG_OFF         "n" /* 关闭LOG打印功能 */


#ifndef qltrace
#define aadltrace(fmt, args...)      aadltrace_output(fmt, ##args) 
#define LOG_MACRO(lvl_str)   ("[" LOG_TAG lvl_str)
#define aadltrace_output(fmt, ...)  \
do {    \
    char loglevel = (char)*fmt; \
    switch(loglevel) {         \
    case LOG_ERROR_C: elog_output(ELOG_LVL_ERROR,  LOG_MACRO("_E]"), __FILE_NAME__, __FUNCTION__, __LINE__, fmt + 1, ##__VA_ARGS__); break; \
    case LOG_WARN_C:  elog_output(ELOG_LVL_WARN,   LOG_MACRO("_W]"), __FILE_NAME__, __FUNCTION__, __LINE__, fmt + 1, ##__VA_ARGS__); break; \
    case LOG_INFO_C:  elog_output(ELOG_LVL_INFO,   LOG_MACRO("_I]"), __FILE_NAME__, __FUNCTION__, __LINE__, fmt + 1, ##__VA_ARGS__); break; \
    case LOG_DEBUG_C: elog_output(ELOG_LVL_DEBUG,  LOG_MACRO("_D]"), __FILE_NAME__, __FUNCTION__, __LINE__, fmt + 1, ##__VA_ARGS__); break; \
    }   \
} while(0)
#else
#define aadltrace qltrace
#endif


#define aadltrace_enable()
#define aadltrace_disable()


#endif